package org.biliviz.be.controller;


import io.swagger.annotations.ApiOperation;
import org.biliviz.be.entity.AuthorData;
import org.biliviz.be.entity.AuthorInfo;
import org.biliviz.be.entity.vo.AuthorDataVo;
import org.biliviz.be.service.AuthorDataService;
import org.biliviz.be.service.AuthorInfoService;
import org.biliviz.be.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sg
 * @since 2024-03-02
 */
@RestController
@RequestMapping("/api")
public class AuthorInfoController {
    @Autowired
    AuthorInfoService authorInfoService;
    @Autowired
    AuthorDataService authorDataService;

    @GetMapping("/author/info")
    public R authorInfo() {
        List<AuthorInfo> info = authorInfoService.getTop100();
        return R.ok().data("info", info);
    }

    @GetMapping("/author/day/fans/increase")
    public R dayFansIncrease() {
        List<AuthorInfo> info = authorInfoService.getDayFansIncreaseTop100();
        return R.ok().data("info", info);
    }

    @GetMapping("/author/day/fans/decrease")
    public R dayFansDecrease() {
        List<AuthorInfo> info = authorInfoService.getDayFansDecreaseTop100();
        return R.ok().data("info", info);
    }

    @GetMapping("/author/detail/info")
    public R loginUser(@RequestParam Long mid) {
        AuthorInfo info = authorInfoService.getAuthorInfo(mid);
        List<AuthorDataVo> data = authorDataService.getAuthorData(mid);
        return R.ok().data("info", info).data("data",data);
    }

    @GetMapping("/author/Top100/iad")
    public R authorTopIAD() {
        List<AuthorInfo> fwcI = authorInfoService.getAuthorTop100ID(2);
        List<AuthorInfo> fdcI = authorInfoService.getAuthorTop100ID(1);
        List<AuthorInfo> fans = authorInfoService.getAuthorTop100ID(0);
        List<AuthorInfo> fdcD = authorInfoService.getAuthorTop100ID(-1);
        List<AuthorInfo> fwcD = authorInfoService.getAuthorTop100ID(-2);
        return R.ok().data("fdcI",fdcI)
                .data("fwcI",fwcI)
                .data("fans",fans)
                .data("fdcD",fdcD)
                .data("fwcD",fwcD);
    }

    @GetMapping("/author/like/info")
    public R loginUser(@RequestParam String name) {
        List<AuthorInfo> info = authorInfoService.getAuthorInfoLike(name);
        return R.ok().data("info", info);
    }


}
